#!/bin/bash

apt update
apt install -y axel
apt install -y cmake
apt install -y libgtest-dev
apt install -y openssl
apt install -y libssl-dev
apt install -y pkg-config
apt install -y zlib1g-dev
apt install -y libssh2-1-dev
apt install -y libpng-dev
apt install -y npm
apt install -y webpack

mkdir /root/lib
mkdir /root/lib/build

# zlib for boost
cd /root/lib
wget https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
tar zxf zlib-1.2.11.tar.gz
cd

# boost
cd /root/lib
axel -n 32 https://jaist.dl.sourceforge.net/project/boost/boost/1.72.0/boost_1_72_0.tar.gz
tar zxf boost_1_72_0.tar.gz
cd /root/lib/boost_1_72_0/
./bootstrap.sh
./b2 install --prefix=/root/lib/build/boost1.72 -sZLIB_SOURCE="/root/lib/zlib-1.2.11" -sZLIB_INCLUDE="/root/lib/zlib-1.2.11"
echo "export BOOST_ROOT=\"/root/lib/build/boost1.72\"" >> /root/.bashrc
export BOOST_ROOT="/root/lib/build/boost1.72"
echo "export LD_LIBRARY_PATH=\"\${BOOST_ROOT}/lib\"" >> /root/.bashrc
export LD_LIBRARY_PATH="${BOOST_ROOT}/lib"
cd

# gtest
cd /root/lib
axel -n 32 https://codeload.github.com/google/googletest/tar.gz/release-1.10.0
tar zxf googletest-release-1.10.0.tar.gz
cd googletest-release-1.10.0
mkdir build
cd build
cmake ..
make install
cd

# abc-server
echo "export ABC_SERVER_THIS_IS_RELEASE_MACHINE=\"1\"" >> /root/.bashrc
export ABC_SERVER_THIS_IS_RELEASE_MACHINE="1"
echo "export ABC_SERVER_CONFIG_FILE_PATH=\"/root/abc-server/abc-server-config.txt\"" >> /root/.bashrc
export ABC_SERVER_CONFIG_FILE_PATH="/root/abc-server/abc-server-config.txt"

# abc-server-resource
cd /root
git clone https://gitee.com/haocxy/abc-server-resource.git
cd /root/abc-server-resource/src
npm install
npm start
cd

# build abc-server
cd /root/abc-server
rm -rf build
mkdir build
cd build
cmake ..
make

